package com.funny.learning.english.activity;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.funny.learning.english.BaseActivity;
import com.funny.learning.english.R;
import com.funny.learning.english.api.BaseAjaxCallBack.IAjaxCallbackMMK;
import com.funny.learning.english.api.TiengAnhApi;

public class ResetPassActivity extends BaseActivity{
	private Button btReset;
	private EditText edtReNewPass;
	private EditText edtNewPass;
	private EditText edtPass;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.rs_pass_layout);
		btReset = (Button)findViewById(R.id.btReset);
		edtReNewPass = (EditText)findViewById(R.id.edtReNewPass);
		edtNewPass = (EditText)findViewById(R.id.edtNewPass);
		edtPass = (EditText)findViewById(R.id.edtPass);
		
		btReset.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View paramView) {
				String pass = edtPass.getText().toString();
				String newPass = edtNewPass.getText().toString();
				String reNewPass = edtReNewPass.getText().toString();
				
				if(!pass.isEmpty() && newPass.isEmpty() && reNewPass.isEmpty()){
					if (pass.equals("1234")) {
						if(newPass.equals(reNewPass)){
							TiengAnhApi.resetPass("", pass, newPass, activity, ajaxCallbackMMK);
						}else{
							//Nhap Pass moi khong trung
						}
					}else{
						//Pass nhap khong chinh xac
					}
				}
			}
		});
	}
	
	private IAjaxCallbackMMK ajaxCallbackMMK = new IAjaxCallbackMMK() {
		@Override
		public <T> void handler(T t, int code) {
			if(code == COMPLETE){
				Toast.makeText(activity, "Thanh cong", 1000).show();
			}else if(code == ERROR){
				Toast.makeText(activity, "That bai", 1000).show();
			}
		}
	};
}	
